import 'dart:convert';

import 'package:x_core/net/json/base_entity.g.dart';
import 'package:x_core/net/net_exception.dart';

// @JsonSerializable()
class BaseEntity<T> {
  static const okCode = 200;

  int code = NetException.unknownException;
  String? message;
  T? data;

  BaseEntity();

  factory BaseEntity.fromJson(Map<String, dynamic> json) =>
      $BaseEntityFromJson<T>(json);

  Map<String, dynamic> toJson() => $BaseEntityToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}
